public class Leet11 {
    public static void main(String[] args) {
        int[] a = {1,8,6,2,5,4,8,3,7};
        Leet11 l = new Leet11();
        System.out.println(l.maxArea(a));
    }
    public int maxArea(int[] height) {
        int max = 0;
        for (int i = 0; i < height.length-1; i++) {
            for (int j = i+1; j < height.length; j++) {
                int x = j-i;
                int y = height[i]>height[j]?height[j]:height[i];
                max = Math.max(max, x * y);
            }
        }
        return max;
    }
}
